﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Menu.Master" AutoEventWireup="true" CodeBehind="AvanceActividadesForm.aspx.cs" Inherits="Emporium_Web.AvanceActividadesForm" Theme="Constellation" %>

<%@ MasterType VirtualPath="~/Menu.master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register src="Search/OrdenProduccionSearch.ascx" tagname="OrdenProduccionSearch" tagprefix="uc4" %>


<%@ Register src="Search/OrdenCortePaqueteAdd.ascx" tagname="OrdenCortePaqueteAdd" tagprefix="uc1" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript" src="js/funciones.grid.js"></script>          
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <!-- Content -->
    <article class="container_12">
	  
		<section class="grid_12">
			<div class="block-border">
			<form runat="server" class="block-content form" id="table_form">
				<h1>Avance de Actividades</h1>
                 <ajaxtoolkit:toolkitscriptmanager ID="toolk" runat="server"  EnableScriptGlobalization="true" EnableScriptLocalization="true" EnablePageMethods="true"></ajaxtoolkit:toolkitscriptmanager>
                
                <asp:UpdatePanel ID="upnAvanceActividades" runat="server">
                <ContentTemplate>  
             
                <ul class="message warning no-margin" runat="server"  id="warningMessage">
					<li><asp:Label runat="server" ID="lblWarningMessage"></asp:Label></li>
				</ul>
                <ul class="message error no-margin" runat="server" id="errorMessage">
                    <li>
                        <asp:Label runat="server" ID="lblErrorMessage"></asp:Label></li>
                </ul>    

                 <ajaxtoolkit:TabContainer ID="tbcPedido" runat="server" ActiveTabIndex="0">
                 <ajaxtoolkit:TabPanel ID="TabPanel1" runat="server">
                 <HeaderTemplate>Datos Generales</HeaderTemplate>
                 <ContentTemplate>

                 <fieldset>  
                    <br />
                    <div style="width: 100%; height: 45px;">
                        <div style="width: 100px; float: left;">
                            <label>Nro Mov.</label>
                        </div>
                        <div align="left" style="float: left;">
                            <asp:TextBox ID="txtCodigo" runat="server" Width="100px" Enabled="False" Style="text-align:right;"></asp:TextBox>                            
                        </div>
                        <div style="width: 75px; float: left;padding-left:30px;">
                            <label>Fecha</label>
                        </div>
                        <div align="left" style="float: left;">
                            <asp:TextBox ID="txtFechaRegistro" runat="server" Width="100px" Enabled="False"></asp:TextBox>                            
                        </div>
                        <div style="width: 75px; float: left;padding-left:30px;">
                            <label>Usuario</label>
                        </div>
                        <div align="left" style="float: left;">
                            <asp:TextBox ID="txtUsuario" runat="server" Width="200px" Enabled="False"></asp:TextBox>                            
                        </div>
                    </div>  
                    <div style="width: 100%; height: 45px;">
                        <div style="width: 100px; float: left;">
                            <label>O.P.</label>
                        </div>
                        <div align="left" style="float: left;width:80%;">
                            <uc4:OrdenProduccionSearch ID="OrdenProduccionSearch1" runat="server" ValidationGroup="AvanceActividadValidation" OnSeleccionado="OrdenProduccionSearch_Seleccionado"/>
                        </div>
                    </div> 
                    
                     <div style="width: 100%; height: 45px; float: left;">
                        <div style="width: 100px; float: left;">
                            <label>
                                Estilo</label>
                        </div>
                        <div align="left" style="width: 70%; float: left;">
                            <asp:TextBox ID="txtEstilo" runat="server" Width="100px" Enabled="False"></asp:TextBox>                            
                        </div>
                    </div>
                    
                    <div style="width: 100%;">
                        <table width="100%">
                            <tr>
                                <td style ="width:50%">
                                    <asp:Panel ID="pnlOrigen" runat="server" GroupingText="Origen">
                                        <table width="100%">
                                            <tr style="height:45px;">
                                                <td style="width:20%;">
                                                    <label>Proceso</label>
                                                </td>
                                                <td style="width:80%;">
                                                    <asp:DropDownList ID="ddlProcesoOrigen" runat="server" Width="60%" 
                                                        onselectedindexchanged="ddlProcesoOrigen_SelectedIndexChanged" AutoPostBack="true">
                                                    </asp:DropDownList>
                                                    <asp:RequiredFieldValidator id="reqProcesoOrigen" ControlToValidate="ddlProcesoOrigen" ErrorMessage ="Seleccione" Display="Static" 
                                                    InitialValue="0" runat="server"  ValidationGroup="AvanceActividadValidation"/>
                                                    <asp:TextBox ID = "txtProcesoOrigen" runat="server" Visible="false"  Width="60%" Enabled="false"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr style="height:45px;">
                                                <td>
                                                    <label>Actividad</label>
                                                </td>
                                                <td>
                                                    <asp:DropDownList ID="ddlActividadOrigen" runat="server" Width="60%" 
                                                        onselectedindexchanged="ddlActividadOrigen_SelectedIndexChanged" AutoPostBack="true">
                                                    </asp:DropDownList>
                                                      <asp:RequiredFieldValidator id="reqActividadOrigen" ControlToValidate="ddlActividadOrigen" ErrorMessage="Seleccione" Display="Static" 
                                                    InitialValue="0" runat="server"  ValidationGroup="AvanceActividadValidation"/>      
                                                    <asp:TextBox ID = "txtActividadOrigen" runat="server" Visible="false" Width="60%" Enabled="false"></asp:TextBox>
                                                </td>
                                            </tr>
                                            <tr style="height:45px;">
                                                <td>
                                                    <label>Sector</label>
                                                </td>
                                                <td>
                                                    <asp:DropDownList ID="ddlSectorOrigen" runat="server" Width="60%"  Enabled="false"
                                                        onselectedindexchanged="ddlSectorOrigen_SelectedIndexChanged" AutoPostBack="true">
                                                    </asp:DropDownList>
                                                    <asp:RequiredFieldValidator id="reqSectorOrigen" ControlToValidate="ddlSectorOrigen" ErrorMessage="Seleccione" Display="Static" 
                                                    InitialValue="0" runat="server"  ValidationGroup="AvanceActividadValidation"/>      
                                                    <asp:TextBox ID = "txtSectorOrigen" runat="server" Visible="false" Width="60%" Enabled="false"></asp:TextBox>
                                                </td>
                                            </tr>
                                             <tr style="height:45px;">
                                                <td>
                                                    <label>Línea</label>
                                                </td>
                                                <td>
                                                    <asp:DropDownList ID="ddlLineaOrigen" runat="server" Width="60%">
                                                    </asp:DropDownList>
                                                    <asp:RequiredFieldValidator id="reqLineaOrigen" ControlToValidate="ddlLineaOrigen" ErrorMessage="Seleccione" Display="Static" 
                                                    InitialValue="0" runat="server"  ValidationGroup="AvanceActividadValidation"/>  
                                                    <asp:TextBox ID = "txtLineaOrigen" runat="server" Visible="false" Width="60%" Enabled="false"></asp:TextBox>    
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                </td>
                               <td style ="width:50%">
                                      <asp:Panel ID="pnlDestino" runat="server" GroupingText="Destino">
                                        <table width="100%">
                                            <tr style="height:45px;">
                                                <td style="width:20%;">
                                                    <label>Proceso</label>
                                                </td>
                                                 <td style="width:80%;">
                                                    <asp:DropDownList ID="ddlProcesoDestino" runat="server" Width="60%" AutoPostBack="true"
                                                         onselectedindexchanged="ddlProcesoDestino_SelectedIndexChanged">
                                                    </asp:DropDownList>
                                                     <asp:RequiredFieldValidator id="reqProcesoDestino" ControlToValidate="ddlProcesoDestino" ErrorMessage="Seleccione" Display="Static" 
                                                    InitialValue="0" runat="server"  ValidationGroup="AvanceActividadValidation"/>   
                                                    <asp:TextBox ID = "txtProcesoDestino" runat="server" Visible="false" Width="60%" Enabled="false"></asp:TextBox>        
                                                </td>
                                            </tr>
                                            <tr style="height:45px;">
                                                <td>
                                                    <label>Actividad</label>
                                                </td>
                                                <td>
                                                    <asp:DropDownList ID="ddlActividadDestino" runat="server" Width="60%" AutoPostBack="true"
                                                        onselectedindexchanged="ddlActividadDestino_SelectedIndexChanged">
                                                    </asp:DropDownList>
                                                     <asp:RequiredFieldValidator id="reqActividadDestino" ControlToValidate="ddlActividadDestino" ErrorMessage="Seleccione" Display="Static" 
                                                    InitialValue="0" runat="server"  ValidationGroup="AvanceActividadValidation"/>      
                                                    <asp:TextBox ID = "txtActividadDestino" runat="server" Visible="false" Width="60%" Enabled="false"></asp:TextBox>        
                                                </td>
                                            </tr>
                                            <tr style="height:45px;">
                                                <td>
                                                    <label>Sector</label>
                                                </td>
                                                <td>
                                                    <asp:DropDownList ID="ddlSectorDestino" runat="server" Width="60%">
                                                    </asp:DropDownList>
                                                    <asp:RequiredFieldValidator id="reqSectorDestino" ControlToValidate="ddlSectorDestino" ErrorMessage="Seleccione" Display="Static" 
                                                    InitialValue="0" runat="server"  ValidationGroup="AvanceActividadValidation"/>     
                                                    <asp:TextBox ID = "txtSectorDestino" runat="server" Visible="false" Width="60%" Enabled="false"></asp:TextBox>        
                                                </td>
                                            </tr>
                                             <tr style="height:45px;">
                                                <td>
                                                    <label>Línea</label>
                                                </td>
                                                <td>
                                                    <asp:DropDownList ID="ddlLineaDestino" runat="server" Width="60%">
                                                    </asp:DropDownList>
                                                    <asp:RequiredFieldValidator id="reqLineaDestino" ControlToValidate="ddlLineaDestino" ErrorMessage="Seleccione" Display="Static" Enabled="false" 
                                                    InitialValue="0" runat="server"  ValidationGroup="AvanceActividadValidation"/>
                                                    <asp:TextBox ID = "txtLineaDestino" runat="server" Visible="false" Width="60%" Enabled="false"></asp:TextBox>        
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                </td>
                            </tr>
                        </table>
                    </div> 
                    <br />
                     <div style="width: 100%; height: 45px;">
                        <div style="width: 100px; float: left;">
                            <label>Observación</label>
                        </div>
                        <div align="left" style="width:80%; float: left;">
                            <asp:TextBox ID="txtObservacion" runat="server" Width="80%"></asp:TextBox>                              
                        </div>
                    </div> 
                                  
                </fieldset>

                </ContentTemplate>
                </ajaxtoolkit:TabPanel>


               
                <ajaxtoolkit:TabPanel ID="TabPanel2" runat="server">
                <HeaderTemplate>Detalle</HeaderTemplate>
                <ContentTemplate>

                <fieldset>
                 <br />
                 <div style="width:75%; float:left;" align="left">                                        
                     <asp:Panel ID="pnlDetallePorPaquetes" runat="server" Height="400px" ScrollBars="Vertical" Width="100%" style="display:none;">            
                     <asp:GridView ID="gvDetallePorPaquetes" runat="server" SkinID="gridviewSkin" 
                             PageSize="100" Width="100%"
                             AutoGenerateColumns="False" ShowFooter="false" 
                         DataKeyNames = "MovDet_Secuencia" onrowdeleting="gvDetallePorPaquetes_RowDeleting">
                        <HeaderStyle Font-Bold="True"/>                     
                        <Columns>                            
                                     
                             <asp:TemplateField HeaderText="Secuencia"  HeaderStyle-HorizontalAlign="Left">                                                                                                                       
                                <ItemTemplate> 
                                    <asp:Label ID="lblSecuencia" runat="server" Text='<%# Bind("MovDet_Secuencia","{0:000}") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="10%" />
                            </asp:TemplateField>
                                                                          
                           <asp:TemplateField HeaderText="Orden Corte" HeaderStyle-HorizontalAlign="Left">
                                <ItemTemplate> 
                                    <asp:Label ID="lblOrdenCorte" runat="server" Text='<%# Eval("OrdCor_Id","{0:00000}") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="15%" />
                            </asp:TemplateField> 
                            
                             <asp:TemplateField HeaderText="Paquete" HeaderStyle-HorizontalAlign="Left">
                                <ItemTemplate> 
                                    <asp:Label ID="lblPaquete" runat="server" Text='<%# Eval("OrdCorPaq_Numero","{0:000}") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="15%" />
                            </asp:TemplateField>                           
                            
                             <asp:TemplateField HeaderText="Etiqueta" HeaderStyle-HorizontalAlign="Left">
                                <ItemTemplate> 
                                    <asp:Label ID="lblEtiqueta" runat="server" Text='<%# Eval("MovDet_Color") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="15%" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Talla" HeaderStyle-HorizontalAlign="Left">
                                <ItemTemplate> 
                                    <asp:Label ID="lblTalla" runat="server" Text='<%# Eval("MovDet_Talla") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="15%" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Avance" HeaderStyle-HorizontalAlign="Left">
                                <ItemTemplate> 
                                    <asp:Label ID="lblAvance" runat="server" Text='<%# Eval("MovDet_Avance") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="15%" />
                            </asp:TemplateField>

                            <asp:TemplateField ShowHeader="False" HeaderStyle-HorizontalAlign="Left">
                                 <ItemTemplate> 
                                    <asp:ImageButton ID="imgDelete" runat="server" CausesValidation="False" CommandName="Delete"  ImageUrl="~/images/icons/web-app/24/Delete.png" OnClientClick="return DeleteRegistro();" ToolTip="Eliminar"></asp:ImageButton> 
                                </ItemTemplate>                               
                                 <ItemStyle Width="2%" />
                            </asp:TemplateField>     
                                                 
						</Columns>  						
					</asp:GridView>   
                    
                     <div align="left" style="width:100%; float:inherit; vertical-align:middle; padding-top:15px;">
					        <asp:LinkButton ID="btnPaqueteAdicionar" runat="server" Text="Adicionar" 
                                CssClass="button" onclick="btnPaqueteAdicionar_Click"/>
				            
				            <uc1:OrdenCortePaqueteAdd ID="ordenCortePaqueteAdd" runat="server" OnSeleccionado ="ordenCortePaqueteAdd_Seleccionado"/>		            
				    </div>   
                         
                    </asp:Panel>

                     <asp:Panel ID="pnlDetallePorPrendas" runat="server" Height="400px" ScrollBars="Vertical" Width="100%" style="display:none;">            
                     
                     <asp:GridView ID="gvDetallePorPrendas" runat="server" SkinID="gridviewSkin" PageSize="100" Width="100%"
                            AutoGenerateColumns="False" ShowFooter="True" DataKeyNames = "MovDet_Secuencia" onrowcommand="gvDetallePorPrendas_RowCommand" 
                         onrowdeleting="gvDetallePorPrendas_RowDeleting">
                        <HeaderStyle Font-Bold="True"/>                     
                        <Columns>                            
                                     
                            <asp:TemplateField HeaderText="Secuencia"  HeaderStyle-HorizontalAlign="Left">                                                                                                               
                                <ItemTemplate> 
                                    <asp:Label ID="lblSecuencia" runat="server" Text='<%# Bind("MovDet_Secuencia","{0:000}") %>'></asp:Label> 
                                </ItemTemplate> 
                                <ItemStyle Width="10%" />
                            </asp:TemplateField>                                                                          
                         
                             <asp:TemplateField HeaderText="Etiqueta" HeaderStyle-HorizontalAlign="Left">
                                <FooterTemplate>                                     
                                    <asp:DropDownList ID="ddlEtiquetaNew" runat="server" Width="200px" onselectedindexchanged="ddlEtiquetaNew_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>                                     
                                    <asp:RequiredFieldValidator ID="reqEtiquetaNew" runat="server" ControlToValidate="ddlEtiquetaNew" InitialValue="0" Text="Valor requerido" ValidationGroup ="AgregarPrendas"></asp:RequiredFieldValidator>
                                </FooterTemplate>                                 
                                <ItemTemplate> 
                                    <asp:Label ID="lblEtiqueta" runat="server" Text='<%# Eval("MovDet_Color") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Talla" HeaderStyle-HorizontalAlign="Left">
                                <FooterTemplate>                                     
                                    <asp:DropDownList ID="ddlTallaNew" runat="server" Width="200px"></asp:DropDownList>                                     
                                    <asp:RequiredFieldValidator ID="reqTallaNew" runat="server" ControlToValidate="ddlTallaNew" InitialValue="0" Text="Valor requerido" ValidationGroup ="AgregarPrendas"></asp:RequiredFieldValidator>
                                </FooterTemplate>                                 
                                <ItemTemplate> 
                                    <asp:Label ID="lblTalla" runat="server" Text='<%# Eval("MovDet_Talla") %>'></asp:Label>                                     
                                </ItemTemplate> 
                                <ItemStyle Width="25%" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="Avance" HeaderStyle-HorizontalAlign="Left">
                                <FooterTemplate>                                     
                                    <asp:TextBox ID="txtAvanceNew" runat="server" Width="120px" MaxLength="3"></asp:TextBox>                                     
                                    <asp:RequiredFieldValidator ID="reqAvanceNew" runat="server" ControlToValidate="txtAvanceNew" Text="Valor requerido" ValidationGroup ="AgregarPrendas"></asp:RequiredFieldValidator>
                                </FooterTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="lblAvanceId" runat="server" style=" display:none;" Text='<%# Eval("MovDet_Secuencia") %>'></asp:Label> 
                                    <asp:TextBox ID="txtAvance" runat="server" Width="120px" MaxLength="3" onKeyPress ='return ValidarInputNumerico(event)' onChange='ActualizarAvance(event,this)' Text='<%# Eval("MovDet_Avance") %>' ></asp:TextBox>
                                </ItemTemplate> 
                                <ItemStyle Width="10%" />
                            </asp:TemplateField>

                            <asp:TemplateField ShowHeader="False" HeaderStyle-HorizontalAlign="Left">
                                <FooterTemplate> 
                                    <asp:ImageButton ID="imgAdd" runat="server" CausesValidation="True" CommandName="Insert" ValidationGroup = "AgregarPrendas" ImageUrl="~/images/icons/web-app/24/Save.png" ToolTip ="Agregar"></asp:ImageButton> 
                                </FooterTemplate> 
                                 <ItemTemplate> 
                                    <asp:ImageButton ID="imgDelete" runat="server" CausesValidation="False" CommandName="Delete"  ImageUrl="~/images/icons/web-app/24/Delete.png" OnClientClick="return DeleteRegistro();" ToolTip="Eliminar"></asp:ImageButton> 
                                </ItemTemplate>                               
                                 <ItemStyle Width="5%" />
                            </asp:TemplateField>         
                                                 
						</Columns>  						
					</asp:GridView>                                     
                   
                    </asp:Panel>

                </div>				

                    
                    

                    
                </fieldset>			                

                 </ContentTemplate>
                 </ajaxtoolkit:TabPanel>

                 </ajaxtoolkit:TabContainer>

                 <br />
                 <fieldset class="grey-bg no-margin">
				<br />
						<asp:LinkButton ID="btnGrabar" runat="server" CssClass="button red" 
                        Text="Grabar"  ValidationGroup="AvanceActividadValidation" 
                        onclick="btnGrabar_Click"></asp:LinkButton>
                        <asp:LinkButton ID="btnAtras" runat="server" CssClass="button red" 
                        Text="Atrás" CausesValidation="false" onclick="btnAtras_Click"></asp:LinkButton>
				</fieldset>

                </ContentTemplate>
                </asp:UpdatePanel>


			</form>
			</div>
		</section>
	</article>

    <script type="text/javascript">


        function ActualizarAvance(e, txt) {
            PageMethods.ActualizarAvance($(txt).parent()[0].children[0].innerHTML, $(txt).parent()[0].children[1].value);
            return false;
        }

        function ValidarInputNumerico(e) {
            var valid = "0123456789"
            return ValidaInput(valid, e);
        }
        
        function ValidarInputDecimal(e) {
            var valid = "0123456789.";
            return ValidaInput(valid, e);

        }

        function ValidaInput(valid, e) {
            var keyAscii = (document.all) ? event.keyCode : e.which;
            if (keyAscii != 13) {
                var key = String.fromCharCode(keyAscii);
                var keyAj = key.toUpperCase();
                if (valid == '') {
                    return true;
                }
                if (valid.indexOf(keyAj) == "-1") {
                    if (keyAscii != 8 && keyAscii != 0) { return false };
                    return true;
                }
                return true;
            }
        }

    </script>
</asp:Content>
